using System;
using System.Collections.Generic;
using UnityEngine;
using QFramework;

namespace ProjectMyFarmAndShe
{
	public partial class Player : ViewController,IController
	{
		private Vector2 mInput;

		private void Awake()
		{
			Global.Player = this;
		}

		void Start()
		{
			// Code Here
			Application.targetFrameRate = 60;
		}

		private void FixedUpdate()
		{
			SelfRigidbody2D.velocity = mInput * 3;
		}

		private void Update()
		{
			mInput.x = Input.GetAxisRaw("Horizontal");
			mInput.y = Input.GetAxisRaw("Vertical");
			mInput = mInput.normalized;

			if (mInput.x < 0)
			{
				Sprite.flipX = true;
			}
			else if (mInput.x > 0)
			{
				Sprite.flipX = false;
			}
			
			Anima.SetBool("Move",mInput != Vector2.zero ? true : false);
			
			#region 退出测试按钮

			if (Input.GetKeyDown(KeyCode.Escape))
			{
				Application.Quit();
			}

			#endregion
			
		}

		public IArchitecture GetArchitecture()
		{
			return Global.Interface;
		}
	}
}
